package com.wnxy.consumer.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.netflix.hystrix.contrib.javanica.conf.HystrixPropertiesManager;
import com.wnxy.common.result.Result;
import com.wnxy.stu.api.TestProductApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yellow Docter
 * @date 2024 -04-18
 * @desc
 */
@RestController
@RequestMapping("consumer")
public class TestConsumerController {

    @Autowired
    private TestProductApi testProductApi;

    /**
     *   01  testProductApi.listById(id)  这个服务超时
     *   02  testProductApi.listById(id)  远程服务关闭
     * @param id
     * @return
     */
    @GetMapping("test/find/{id}")
//    @HystrixCommand(fallbackMethod = "fallBack")
    public Result testHystrixCommand(@PathVariable ("id") Integer id){

        Result result = testProductApi.listById(id);
        return result;

    }

//    public Result fallBack(@PathVariable ("id") Integer id){
//        return Result.fail("超时或者 调用失败走服务降价的方法...");
//    }

}
